package com.ruoyi.web.service;

import com.ruoyi.common.utils.http.HttpUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class WxUserService {
    @Value("${wxmini.appid}")
    private String appid;

    @Value("${wxmini.secret}")
    private String secret;

    /**
     *     从后端通过用户传来的code向微信端口进行验证
     *
     *                              */
    public String getSessionID(String code){
        String url = "https://api.weixin.qq.com/sns/jscode2session";
        String params = "appid="+appid+"&secret="+secret+"&js_code="+code+"&grant_type=authorization_code";
        String res = HttpUtils.sendSSLPost(url,params);
        return res;
    }


}
